//
//  UIImage+Rotate.m
//  BabyNow
//
//  Created by 刘泽琛 on 14-5-19.
//  Copyright (c) 2014年 iMobile. All rights reserved.
//

#import "UIImage+Rotate.h"

@implementation UIImage (Rotate)

- (UIImage*)rotateImageByAngle:(NSString *)angle{
    CGSize rotatedSize = self.size;
    UIGraphicsBeginImageContext(rotatedSize);
    CGContextRef ctx = UIGraphicsGetCurrentContext();
    CGContextTranslateCTM(ctx, rotatedSize.width / 2, rotatedSize.height / 2);
    CGContextRotateCTM(ctx, M_PI * [angle intValue] / 180);
    CGContextScaleCTM(ctx, 1.0, -1.0);
    CGContextDrawImage(ctx, CGRectMake(-self.size.width / 2, -self.size.height / 2, self.size.width, self.size.height), [self CGImage]);
    UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();
    return newImage;
}

@end
